//
//  HZComCell.swift
//  weibo002
//
//  Created by 黑眼圈 on 16/4/26.
//  Copyright © 2016年 heiyan. All rights reserved.
//

import UIKit

class HZComCell: UICollectionViewCell {
    
    
    //定义取消按钮的闭包
    var cleanClosure:(()->())?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    //添加子控件
    private func setupUI(){
        
        
        addSubview(icon)
        addSubview(btn)
        
        
        //约束
        icon.snp_makeConstraints { (make) -> Void in
            
            make.edges.equalTo(self.contentView)
        }
        
        btn.snp_makeConstraints { (make) -> Void in
            
            make.trailing.equalTo(self.contentView)
            make.top.equalTo(self.contentView)
        }
        
        
        
        
        
    }
    
    
    
    
    
    
    // MARK: -  懒加载子控件
    lazy var icon:UIImageView = {
        
        let icon = UIImageView()
       
        
        return icon
    }()
    
    
    lazy var btn:UIButton = {
        
       let btn = UIButton()
        
        //监听按钮点击事件
        btn.addTarget(self, action: "didClean", forControlEvents: .TouchUpInside )
        
        btn.setImage(UIImage(named: "compose_photo_close"), forState: .Normal)
        
        btn.sizeToFit()
        
        return btn
    }()
    
    
    // MARK: -  实现取消按钮的点击事件
    @objc private func didClean(){
        
        //实现闭包
        cleanClosure!()
    }
    
    
}
